#include <iostream>

using namespace std;

static bool prime(uint64_t n) {
    if (n < 2)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;

    for (uint64_t i = 3; i * i <= n; i += 2) {
        if (n % i == 0)
            return false;
    }

    return true;
}

int main() {
    uint64_t num_total = 1;
    uint64_t num_prime = 0;
    for (uint64_t a = 3; ; a += 2) {
        uint64_t p0 = a * a;
        uint64_t p1 = p0 - (a - 1);
        uint64_t p2 = p1 - (a - 1);
        uint64_t p3 = p2 - (a - 1);
        if (prime(p1)) ++num_prime;
        if (prime(p2)) ++num_prime;
        if (prime(p3)) ++num_prime;
        num_total += 4;
        if (num_prime * 10 < num_total) {
            cout << a << endl;
            break;
        }
    }
}